package com.jingyanzi.finance.service.impl;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/**
 * @author reagan
 * @Description:基础服务类主要用来实现底层的通用方法
 */
public class BaseServiceImpl {
	
	public static Map<Integer, String> PAY_METHOD_NAMES = null;
	
	//public static Map<Integer, String> PAY_STATUS_NAMES = null;
	
	public static Map<Integer, String> PAY_CASH_NAMES = null;
 
	static {
		PAY_METHOD_NAMES = new HashMap<Integer, String>();
		PAY_METHOD_NAMES.put(1, "支付宝");
		PAY_METHOD_NAMES.put(2, "微信");
		PAY_METHOD_NAMES.put(3, "现金");
		PAY_METHOD_NAMES.put(4, "余额");
		PAY_METHOD_NAMES.put(5, "转账");
		PAY_METHOD_NAMES.put(6, "银行卡");
		
		/*PAY_STATUS_NAMES = new HashMap<Integer, String>();
		PAY_STATUS_NAMES.put(0, "为支付");
		PAY_STATUS_NAMES.put(1, "已支付");*/
	
		PAY_CASH_NAMES = new HashMap<Integer, String>();
		PAY_CASH_NAMES.put(1, "订单");
		PAY_CASH_NAMES.put(2, "加选");
		PAY_CASH_NAMES.put(3, "充值");
		PAY_CASH_NAMES.put(4, "其他");
		PAY_CASH_NAMES.put(5, "购买会员");
		PAY_CASH_NAMES.put(0, "全部");
	}
	
	public boolean isNumberNotEmpty(Integer value) {
		if(value == null) return false;
		else if(value == 0) return false;
		return true;
	}


	/**
	 * 验证手机号
	 *
	 */
	public static boolean isChinaPhoneLegal(String str) throws PatternSyntaxException {
		String regExp = "^((13[0-9])|(14[5-9]|(15[^4])|(166)|(17[0-8])|(18[0-9])|(19[8,9])))\\d{8}$";
		Pattern p = Pattern.compile(regExp);
		Matcher m = p.matcher(str);
		return m.matches();
	}
}
